package coroutines.exceptions

import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

object CoroutineExceptionTest {
}

suspend fun main() {
    println(1)
    try {
        coroutineScope { //①
            println(2)
            launch { // ②
                println(3)
                launch { // ③
                    println(4.0)
                    delay(100)
                    throw ArithmeticException("Hey!!")
                }
                println(5)
            }
            println(6)
            val job = launch { // ④
                println(7)
                delay(1000)
            }
            try {
                println(8)
                job.join()
                println("9")
            } catch (e: Exception) {
                println("10. $e")
            }
        }
        println(11)
    } catch (e: Exception) {
        println("12. $e")
    }
    println(13)
}